﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Parentmasterpage.master" CodeBehind="UploadPictureToCruises.aspx.vb" Inherits="WebApplicationcruises.UploadPictureToCruises" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style12
        {
            text-align: left;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="style11">
        <tr>
            <td style="border: thin solid #589BB6">
                <b>Add Cruises&gt;&gt; step 2 add picture</b></td>
        </tr>
        <tr>
            <td style="border: thin solid #589BB6">
&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:FormView ID="FormView1" runat="server" DataKeyNames="PId" 
                    DataSourceID="SqlDataSourcePicture" DefaultMode="Insert" Width="561px">
                    <EditItemTemplate>
                        PId:
                        <asp:Label ID="PIdLabel1" runat="server" Text='<%# Eval("PId") %>' />
                        <br />
                        PPath:
                        <asp:TextBox ID="PPathTextBox" runat="server" Text='<%# Bind("PPath") %>' />
                        <br />
                        CrusisesId:
                        <asp:TextBox ID="CrusisesIdTextBox" runat="server" 
                            Text='<%# Bind("CrusisesId") %>' />
                        <br />
                        <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                            CommandName="Update" Text="Update" />
                        &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                            CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <table class="style11">
                            <tr>
                                <td>
                                    Picture path</td>
                                <td class="style12">
                                    <asp:FileUpload ID="FileUpload1" runat="server" />
                                </td>
                                <td>
                                    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                                        CommandName="Insert" Text="Add" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    &nbsp;</td>
                                <td class="style12">
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                        </table>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        PId:
                        <asp:Label ID="PIdLabel" runat="server" Text='<%# Eval("PId") %>' />
                        <br />
                        PPath:
                        <asp:Label ID="PPathLabel" runat="server" Text='<%# Bind("PPath") %>' />
                        <br />
                        CrusisesId:
                        <asp:Label ID="CrusisesIdLabel" runat="server" 
                            Text='<%# Bind("CrusisesId") %>' />
                        <br />
                        <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                            CommandName="Edit" Text="Edit" />
                        &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                            CommandName="Delete" Text="Delete" />
                        &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                            CommandName="New" Text="New" />
                    </ItemTemplate>
                </asp:FormView>
&nbsp;&nbsp;&nbsp;
            </td>
        </tr>
        <tr>
            <td style="border: thin solid #589BB6">
                <asp:DataList ID="DataList1" runat="server" DataKeyField="PId" 
                    DataSourceID="SqlDataSourcePicture">
                    <ItemTemplate>
                        <asp:Image ID="Image1" runat="server" Height="294px" 
                            ImageUrl='<%# Eval("PPath") %>' Width="712px" />
                        <br />
                    </ItemTemplate>
                </asp:DataList>
            </td>
        </tr>
        <tr>
            <td style="border: thin solid #589BB6">
                <asp:SqlDataSource ID="SqlDataSourcePicture" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnectionStringDB %>" 
                    DeleteCommand="DELETE FROM [Pictures] WHERE [PId] = ?" 
                    InsertCommand="INSERT INTO [Pictures] ( [PPath], [CrusisesId]) VALUES ( ?, ?)" 
                    ProviderName="<%$ ConnectionStrings:ConnectionStringDB.ProviderName %>" 
                    SelectCommand="SELECT PId, PPath, CrusisesId FROM Pictures WHERE (CrusisesId = ?)" 
                    
                    UpdateCommand="UPDATE [Pictures] SET [PPath] = ?, [CrusisesId] = ? WHERE [PId] = ?">
                    <DeleteParameters>
                        <asp:Parameter Name="PId" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:SessionParameter Name="PPath" SessionField="fileupload" Type="String" />
                        <asp:SessionParameter Name="CrusisesId" SessionField="cid" Type="Int32" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:SessionParameter Name="?" SessionField="cid" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="PPath" Type="String" />
                        <asp:Parameter Name="CrusisesId" Type="Int32" />
                        <asp:Parameter Name="PId" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                <asp:LinkButton ID="LinkButton1" runat="server" 
                    PostBackUrl="~/UploadVideoToCruises.aspx">Next to Add Video</asp:LinkButton>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
        </tr>
    </table>
</asp:Content>
